package at.exam;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {
	Button searchButton;
	EditText searchText;
	TextView txtName;
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity1_layout);
        searchText = (EditText) findViewById(R.id.editText1);
        txtName = (TextView) findViewById(R.id.textView4);
        searchButton = (Button) findViewById(R.id.button1);
        Intent i=getIntent();
		String name = i.getStringExtra("name");
		txtName.setText(name);
        searchButton.setOnClickListener(new OnClickListener() {
		
			@Override
			public void onClick(View v) {
				String valueString = searchText.getText().toString();
				// TODO Auto-generated method stub
				String value;
				if (valueString != null)
				{
					value= valueString;
				}
				else 
				{
					value="";
				}
				// tao doi tuong Bundle de gui di cung Intent
				Bundle sendBundle = new Bundle();
				sendBundle.putString("value", value);
				//Tao Intent de khoi chay Activity2 va gan sendBundle vao Intent 
				Intent i = new Intent(MainActivity.this,Activity2.class);
				i.putExtras(sendBundle);
				startActivity(i);
			}
		});
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}
